package com.xiaochong.tir.trades.component.akka;

import akka.actor.UntypedActor;
import com.xc.logclient.utils.LogTrace;
import com.xiaochong.tir.common.data.hbasepo.CmcCurrencyInfo;
import com.xiaochong.tir.common.data.hbasepo.MoreThanPercentageSixChange;
import com.xiaochong.tir.common.data.po.ExchangeInfo;
import com.xiaochong.tir.common.util.CollectionUtil;
import com.xiaochong.tir.common.util.DateUtils;
import com.xiaochong.tir.common.util.LogTraceKeysUtils;
import com.xiaochong.tir.trades.service.KActionQuantizationService;
import com.xiaochong.tir.trades.util.SpringContextUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description: 24h资金净流入计算
 * @Author: org
 * @CreateDate: 2018/7/2 19:50
 */
public class AkkaKActionQuantization extends UntypedActor{

    private KActionQuantizationService kActionQuantizationService =
            (KActionQuantizationService) SpringContextUtil.getBean("kActionQuantizationService");
    @Override
    public void onReceive(Object o) throws Exception {
        LogTrace.beginTrace("akka5分钟执行24小时净流入交易所");
        Object o1 = ((Object[]) o)[0];
        Map<String,ExchangeInfo> akkaExchageMap = (Map<String, ExchangeInfo>) o1;
        //akkaExchageMap.put("exchangeList",exchange);
        LogTrace.info("akka5分钟执行24小时净流入交易所","交易所id","定时任务准备计算超过6%");
        try{
            if(akkaExchageMap != null && akkaExchageMap.size() > 0){
                ExchangeInfo exchangeInfo = akkaExchageMap.get("exchange");
                if(exchangeInfo != null && exchangeInfo.getId() != null){
                    kActionQuantizationService.kActionQuantization(exchangeInfo.getId());
                }
            }
        }catch (Exception e){
            e.printStackTrace();
            LogTrace.error(e.getMessage(), e);
        }

        LogTrace.endTrace();
    }
}
